<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>嘉华金融</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="<%=path%>/static/css/reset.css">
	<link rel="stylesheet" href="<%=path%>/static/css/mui.min.css">
	<link rel="stylesheet" href="<%=path%>/static/css/mui.picker.css" rel="stylesheet" />
	<link rel="stylesheet" href="<%=path%>/static/css/mui.poppicker.css" rel="stylesheet" />
	<link rel="stylesheet" href="<%=path%>/static/css/index.css">
	<link rel="stylesheet" href="<%=path%>/static/css/weui.min.css">
</head>
<body>
	<div>
		<div class="header">
			<div><div class="back"></div></div>
			<div>拍拍贷</div>
			<div><div class="user-img"></div><input type="hidden" id="openid" value="${userInfo.openid}"></div>
		</div>
		<div class="main">
			<div class="loan-banner paipai"><img src="<%=path%>/static/img/loan/pai.jpg"></div>
			<form class="loan-wrap">
				<div class="weui-cells">
		            <div class="weui-cell">
		                <div class="weui-cell__hd loan-username loan-icon-s"></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input l-user-name content" id="name" value="${userInfo.name}">
		                </div>
		            </div>
		            <div class="weui-cell">
		                <div class="weui-cell__hd loan-userId loan-icon-s"></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input l-user-id content" id="idNumber" value="${userInfo.idNumber}">
		                </div>
		            </div>
		            <div class="weui-cell">
		                <div class="weui-cell__hd loan-userphone loan-icon-s"></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input l-user-phone content" id="phone"  value="${userInfo.phone}">
		                </div>
		            </div>
		            <div class="weui-cell">
		                <div class="weui-cell__hd loan-usercity loan-icon-s"></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input l-user-city city" id="userResult" readonly value="${userInfo.city}">
		                </div>
		                <div id="showPicker" class="right choose-city  right-code">
							<div class="city-code"></div>
						</div>
		            </div>
		        </div>
		        <div class="error-content loan-error"></div>
		        <div class="application-btn" id="ppd_btn" style="background: rgb(254, 223, 68);">申请</div>
			</form>
		</div>
	</div>
</body>
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/weui.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/city-data.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/chooseCity.js"></script>
<script type="text/javascript" src="<%=path%>/static/layer/layer.js"></script>
<script type="text/javascript">
	var path="<%=path%>";

	getUserListing();

	
	//返回
	$(".back").click(function() {
		window.location = path + "/home.html"
	});

	//申请
	$("#ppd_btn").click(function() {
		var error = $(".loan-error").html();
		if (error != "" && error != " ") {
			return false;
		}
		var openid = $("#openid").val();//openid
		var idNumber = $("#idNumber").val();//身份证号
		var phone = $("#phone").val();//手机号
		var name = $("#name").val();//姓名
		var city = $("#userResult").val();//城市
		var $this = $(this);

		$.ajax({
			url : path + "/home/ppdReg.html",
			type : "POST",
			dataType : "json",
			data : {
				"idNumber" : idNumber,
				"name" : name,
				"phone" : phone,
				"openid" : openid
			},
			success : function(data) {
				var json = eval("(" + data.data + ")");
				if (json.Code == 1) {
					//window.location = decodeURI(decodeURIComponent(json.Content.RedirectUrl));
					layer.msg(json.Msg);
				} else {
					layer.msg(json.Msg);
				}
			},
			error : function(r, s, m) {
			}
		});
	});

	
	//申请前查询当前用户的 查寻信息接口
	function getUserListing() {
		//var data = '{"Code":1,"Msg":"","ExceptionMsg":"","Content":[{"Id":1389045,"Status":1,"SuccessDate":null,"Amount":0,"Month":0,"CurrentRate":null},{"Id":909591,"Status":2,"SuccessDate":null,"Amount":8000.0000,"Month":12,"CurrentRate":22},{"Id":234920,"Status":1,"SuccessDate":null,"Amount":0,"Month":0,"CurrentRate":null},{"Id":234922,"Status":1,"SuccessDate":null,"Amount":0,"Month":0,"CurrentRate":null},{"Id":234925,"Status":1,"SuccessDate":null,"Amount":0,"Month":0,"CurrentRate":null},{"Id":240670,"Status":1,"SuccessDate":null,"Amount":0,"Month":0,"CurrentRate":null},{"Id":241564,"Status":1,"SuccessDate":null,"Amount":0,"Month":0,"CurrentRate":null}]}';
		$.ajax({
			url : path + "/home/getUserListing.html",
			type : "POST",
			dataType : "json",
			data : {
				"phone" : "15555687880",
				"openid" : $("#openid").val()
			},
			success : function(data) {
				debugger
				var json = eval("(" + data + ")");
				if (json.Code == 1) {
					var content = json.Content;
					for ( var i in content) {
						//Id:标编号
						//Status：             3=成功
						//SuccessDate： 放款时间
						//Amount:      放款金额 单位(元)
						//Month:       放款期限 单位(月)
						//CurrentRate: 放款利率 单位(%)
						console.log(i, ":", content[i].Id);
					}
				} else {
					layer.msg(json.Msg);
				}

			},
			error : function(r, s, m) {
			}
		});
	}
</script>
</html>